package com.jyh.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.jyh.db.entity.JyhBasicData;
import com.jyh.db.mapper.JyhBasicDataMapper;
import com.jyh.service.basicBi.BasicService;
import com.jyh.util.Time;

/**
 * 定时任务配置类
 */
@Configuration
@EnableScheduling // 启用定时任务
public class SchedulingConfig {

	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private JyhBasicDataMapper dataMapper;
	@Autowired
	private BasicService basicService;

	// }
	/**
	 * 昨日基本信息定时任务
	 */
	@Scheduled(cron = "0 1 0 * * ?") // 每20秒执行一次
	public void scheduler2() {
		logger.info("昨日基本信息定时任务开始");
		String time = Time.getTimes();
		JyhBasicData vo = basicService.oldServe(time);
		int id = dataMapper.insert(vo);
		logger.info("昨日基本信息定时任务结束，执行结果：{}",id);
	}

}
